package chapter08;

import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.util.Scanner;

/**
 * Created by V5470-I5 on 2016/3/31.
 */
import java.io.*;
import java.util.Scanner;
public class FileUtil1 {
    public static String readFile1(String name) throws FileNotFoundException {
        StringBuilder text=new StringBuilder();
        Scanner console=null;
        try{
            console=new Scanner(new FileInputStream(name));
            while (console.hasNext()){
                text.append(console.nextLine())
                        .append('\n');
            }
        }
        finally {
            if (console !=null){
                console.close();
            }
        }
        return text.toString();
    }
}
